<?php $__env->startSection('main'); ?>

	<!-- 引入CSS -->
	<link rel="stylesheet" href="/up/uploadify.css">
	<!-- 引入JQ -->
	<!--引入过了-->
	<!-- 引入文件上传插件 -->
	<script src="/up/jquery.uploadify.min.js"></script>


	<!-- 内容 -->
	<div class="col-md-10">

		<ol class="breadcrumb">
			<li><a href="#"><span class="glyphicon glyphicon-home"></span> 首页</a></li>
			<li><a href="#">系统管理</a></li>
			<li class="active">轮播图列表</li>

			<button class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-refresh"></span></button>
		</ol>

		<!-- 面版 -->
		<div class="panel panel-default">
			<div class="panel-heading">
				<button class="btn btn-danger">轮播图展示</button>
				<a href="javascript:;" data-toggle="modal" data-target="#add" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> 添加轮播图</a>


				<p class="pull-right tots" >共有 <?php echo e($tot); ?> 条数据</p>
				<form action="" class="form-inline pull-right">
					<div class="form-group">
						<input type="text" name="search" class="form-control" placeholder="请输入你要搜索的内容" id="">
					</div>

					<input type="submit" value="搜索" class="btn btn-success">
				</form>


			</div>
			<table class="table-bordered table table-hover">

				<th>ID</th>
				<th>IMG</th>
				<th>HREF</th>
				<th>TITLE</th>
				<th>ORDER</th>
				<th>操作</th>
				<?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
					<tr>
						<td><?php echo e($value->id); ?></td>
						<td><img style="width:140px;" src="/Uploads/lun/<?php echo e($value->img); ?>"></td>
						<td><?php echo e($value->href); ?></td>
						<td><?php echo e($value->title); ?></td>
						<td><?php echo e($value->order); ?></td>
						<td><a href="javascript:;" onclick="edit(<?php echo e($value->id); ?>)" data-toggle="modal" data-target="#edit" class="glyphicon glyphicon-pencil"></a>&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="del(<?php echo e($value->id); ?>)" class="glyphicon glyphicon-trash"></a></td>
					</tr>
				<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

			</table>
			<!-- 分页效果 -->
			<div class="panel-footer">
				<nav style="text-align:center;">
					<?php echo e($data->links()); ?>

				</nav>

			</div>
		</div>
	</div>


	<!-- 添加页面摸态框 -->
	<div class="modal fade" id="add">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<h4 class="modal-title">添加轮播图</h4>
				</div>
				<div class="modal-body">


					<form action="" enctype="multipart/form-data" method="post" onsubmit="return false;" id="formAdd" ><!-- onsubmit="return false;"阻止表单提交 -->
						<div class="form-group">
							<label for="">Title</label>
							<input type="text" name="title" class="form-control" placeholder="请输入Title" id="">
							<div id="userInfo">

							</div>
						</div>
						<div class="form-group">
							<label for="">Href</label>
							<input type="text" name="href" class="form-control" placeholder="友情链接" id="">
							<div id="passInfo">

							</div>
						</div>
						<div class="form-group">
							<label for="">Order</label>
							<input type="number" name="order" class="form-control" placeholder="数值越大越靠前" id="">
						</div>
						<div class="form-group">
							<label for="">Img</label>

							<input type="file" name="" id="uploads">
							<div id="main">

							</div>
							<input type="hidden" name="img" id="imgs">

						</div>

						<div class="form-group pull-right">
							<input type="submit" value="提交"  onclick="add()" class="btn btn-success">
							<input type="reset" value="重置" class="btn btn-danger">
						</div>

						<div style="clear:both"></div>
					</form>
				</div>

			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->


	<!-- 修改页面摸态框 -->
	<div class="modal fade" id="edit">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<h4 class="modal-title">修改轮播图</h4>
				</div>
				<div class="modal-body" id="body">




				</div>

			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->



	<script>

        //ajax修改的方法 (页面)
        function edit(id){
            //发送ajax请求
            $.get("/admin/sys/slider/"+id+"/edit",{},function(data){
                //alert(data);
                if(data){
                    $('#body').html(data);
                }
            });
        }



        //当所有HTML代码都加载完毕
        $(function(){
            //声明字符串
            var imgs="";

            //使用 uploadify 插件
            $('#uploads').uploadify({
                //设置文本
                'buttonText':'图片上传',
                //设置文件传输数据
                'formData':{
                    '_token':'<?php echo e(csrf_token()); ?>',
                    'files':'lun',
                },
                //上传的flash动画
                'swf' :"/up/uploadify.swf",
                //文件上传地址
                'uploader':"<?php echo e(asset('admin/shangchuan')); ?>",
                //当文件上传成功
                'onUploadSuccess':function(file,data,response){

                    //alert(data);

                    //拼接字符串
                    imgs="<img width='200px' src='/Uploads/lun/"+data+"'>";
                    //展示图片
                    $("#main").html(imgs);
                    //隐藏域传递数据
                    $('#imgs').val(data);

                }

            });

        });


        //添加的处理操作
        function add(){
            //表单序列化
            str = $('#formAdd').serialize();

            //提交到下一个页面
            $.post('/admin/sys/slider',{'str':str,'_token':'<?php echo e(csrf_token()); ?>'},function(data){
                alert(data);
                if(data==1){
                    //关闭弹框
                    $(".close").click();
					/*	//表单重置
					 $('#reset').click();
					 //清空提示信息
					 $("#userInfo").html('');
					 $("#passInfo").html('');*/
                    window.location.reload();
                }else if(data){ //data存在的时候
                    //alert(data.name[0]);//data.name 是数组
                    //alert(data.pass);
                    //用户名的提示信息
                    var str="";
                    if(data.title){
                        str="<div class='alert alert-danger'>"+data.title+"</div>";
                    }else{
                        str="<div class='alert alert-success'>√</div>";
                    }
                    $("#userInfo").html(str);
                    //链接提示信息
                    if(data.href){
                        str="<div class='alert alert-danger'>"+data.href+"</div>";
                    }else{
                        str="<div class='alert alert-success'>√</div>";
                    }
                    $("#passInfo").html(str);


                }else{
                    alert('添加失败');
                }

            });
        }

	</script>


<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.public.admin', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>